const { Sequelize, DataTypes } = require('sequelize');
const config = require('../config/config.js');
const sequelize = new Sequelize(config);

let commentModel = sequelize.define(
    'comment',
    {
        // 在这里定义模型属性
        user_id: {
            type: DataTypes.STRING,
            comment: '用户ID'
        },
        article_id: {
            type: DataTypes.STRING,
            comment: '文章ID'
        },
        content: {
            type: DataTypes.STRING,
            comment: '内容'
        },
        status: {
            type: DataTypes.STRING,
            comment: '状态'
        },
        created_time: {
            type: Sequelize.INTEGER,
            comment: '创建时间',
            defaultValue: Date.parse(new Date()) / 1000
        },
        updated_time: {
            type: Sequelize.INTEGER,
            comment: '更新时间',
            defaultValue: Date.parse(new Date()) / 1000
        }
    },
    {
        // 这是其他模型参数
        timestamps: false,
        tableName: 'comment'
    }
);

module.exports = commentModel;
